package com.tanhua.admin.mapper;

import cn.hutool.core.date.DateTime;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.tanhua.model.domain.Analysis;
import com.tanhua.model.vo.FindData;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.Date;
import java.util.List;


public interface AnalysisMapper extends BaseMapper<Analysis> {

    @Select("select sum(${column}) from tb_analysis_by_day where record_date > #{leDate} and record_date < #{gtDate}")
    Integer sumAnalysisData(@Param("gtDate") Date gtDate, @Param("leDate") Date leDate, @Param("column") String column);

    @Select("select sum(num_active)  FROM tb_analysis_by_day where record_date between #{offDate} AND #{currentDate}")
    Integer activeUserCounts(@Param("currentDate") DateTime currentDate,@Param("offDate") DateTime  offDate);

    @Select("select sum(${column}) from tb_analysis_by_day where record_date=#{currentDate}")
    Integer sumAnalysisToday(@Param("currentDate") DateTime currentDate,@Param("column") String column);

    @Select("select sum(${column}) from tb_analysis_by_day where record_date=#{currentDate}")
    Integer sumLastToday(@Param("current") Date currentDate,@Param("column") String column);

    //查询 新增、活跃用户、次日留存率
    @Select("select num_registered,num_active,num_retention1d,record_date from tb_analysis_by_day where record_date between  #{thisStartDate} and #{thisEndDate}")
    List<FindData> analysisData(String thisStartDate, String thisEndDate);

}
